package com.ibp.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ibp.entity.ProjectMgr;
import com.ibp.response.DataResponse;
import com.ibp.response.FormResponse;
import com.ibp.response.SimpleResponse;
import com.ibp.service.ProjectMgrService;


@Controller
@RequestMapping("projMgr")
public class ProjectMgrController {
	
	private static Logger logger = LoggerFactory
			.getLogger(ProjectMgrController.class);
	
	@Autowired 
	ProjectMgrService projMgrServiceImpl;

	
	/**  																				  
	 * 删除 project 																			      
	 * @param app  															  
	 */  																				  
	@ResponseBody  																		  
	@RequestMapping("/deleteProj") 															  
	public SimpleResponse<Void> deleteProj(ProjectMgr project){  					  
		logger.info("删除project-->"+project.toString());  							  
		SimpleResponse<Void> response = new SimpleResponse<Void>();
		project.setProject(project.getProject().trim());
		projMgrServiceImpl.deleteProject(project);  												  
		response.setSuccess(true);  													  
		return response;  																  
	}
	
	/***  																				  
	 * 修改 																			      
	 * @param project  															  
	 */  																				  
	@ResponseBody  																		  
	@RequestMapping("/updateProj")  														  
	public FormResponse<String> updateProj(ProjectMgr project){  					  
		logger.info("修改project-->"+project.toString());  							  
		FormResponse<String> response = new FormResponse<String>();  	
		project.setProject(project.getProject().trim());
		response.setData(projMgrServiceImpl.updateProject(project));
		response.setMessage("修改成功！");  											  
		return response;  																  
	} 
	
	/*** 																	              
	 * 新增 																			      
	 * @param project 															  
	 */  																				  
	@ResponseBody  																		  
	@RequestMapping("/addProj")  															  
	public FormResponse<String> addProj(ProjectMgr project){  					  
		logger.info("新增project-->"+project.toString());  							  
		FormResponse<String> response = new FormResponse<String>();  
		project.setProject(project.getProject().trim());
		response.setData(projMgrServiceImpl.addProject(project));											  																			  
		return response;  															      
	} 
	
	/*** 																	              
	 * 查询app列表 																			      
	 * @param app 															  
	 */
	@RequestMapping({"/getProjList"})
	  @ResponseBody
	  public DataResponse<List<ProjectMgr>> getProjList(ProjectMgr project)
	  {
	    logger.info("节点-交易码关系查询" + project.toString());
	    DataResponse<List<ProjectMgr>> response = new DataResponse<List<ProjectMgr>>();
	    response.setData(this.projMgrServiceImpl.getProjectList(project));
	    return response;
	  }
}
